home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / kerberos / pc / krb_libk.lha / Lib / KRB / NETWRITE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-01  |  1.0 KB  |  52 lines

  1. /*
  2.  * $Source: /mit/kerberos/src/lib/krb/RCS/netwrite.c,v $
  3.  * $Author: jtkohl $
  4.  *
  5.  * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
  6.  *
  7.  * For copying and distribution information, please see the file
  8.  * <mit-copyright.h>.
  9.  */
  10.  
  11. #ifndef    lint
  12. static char rcsid_netwrite_c[] =
  13. "$Header: netwrite.c,v 4.1 88/11/15 16:48:58 jtkohl Exp $";
  14. #endif    lint
  15.  
  16. #include <mit_copy.h>
  17. #include <conf.h>
  18. #include <sys/socket.h>
  19.  
  20. /*
  21.  * krb_net_write() writes "len" bytes from "buf" to the file
  22.  * descriptor "fd".  It returns the number of bytes written or
  23.  * a write() error.  (The calling interface is identical to
  24.  * write(2).)
  25.  *
  26.  * XXX must not use non-blocking I/O
  27.  */
  28.  
  29. int
  30. krb_net_write(fd, buf, len)
  31. int fd;
  32. register char *buf;
  33. int len;
  34. {
  35.     int cc;
  36.     register int wrlen = len;
  37.     do {
  38. #ifdef IBMPC
  39.     cc = sowrite(fd, buf, wrlen);
  40. #else
  41.     cc = write(fd, buf, wrlen);
  42. #endif
  43.     if (cc < 0)
  44.         return(cc);
  45.     else {
  46.         buf += cc;
  47.         wrlen -= cc;
  48.     }
  49.     } while (wrlen > 0);
  50.     return(len);
  51. }
  52.